A Gray Code for Combinations of a Multiset
نویسندگان
چکیده
Let C k n n nt denote the set of all k element combinations of the multiset consisting of ni occurrences of i for i t Each combination is itself a multiset For example C ff g f g f g f gg We show that multiset combinations can be listed so that successive combina tions di er by one element Multiset combinations simultaneously generalize for which minimal change listings called Gray codes are known compositions and combinations Research supported by NSERC grant A Research supported by National Science Foundation Grant No CCR and National Security Agency Grant No MDA H Introduction By C k n n nt we denote the set of all ordered t tuples x x xt satisfying x x xt k where xi ni for i t We assume throughout the paper that ni is a positive integer for i t Solutions to are referred to as combinations of a multiset because they can be regarded as k subsets of the multiset consisting of ni copies of i for i t Solution x x xt corresponds to the k subset consisting of xi copies of i for i t For example C corresponds to ff g f g f g f gg When each ni is the set C k n n nt is simply the set of all combinations of t elements chosen k at a time Alternatively the elements of C k n n nt can be regarded as placements of k identical balls into t labeled boxes where the ith box can hold at most ni balls i e compositions of k into t parts in which the ith part is at most ni Under this interpretation C f g When each ni is at least k C k n n nt is the set of all compositions of k into t parts These are frequently occurring combinatorial objects and it is natural to consider e cient algorithms for generating them In particular we will focus on listing multiset combinations in a minimal change order Minimal change listings of combinatorial objects are called Gray codes after Frank Gray who patented a scheme for listing n bit strings so that successive strings di er in just one bit We adopt the convention that lower case bold letters represent t tuples e g a a a at Two elements x y of C k n are adjacent if there are indices p and q such that xi yi for i p q where in addition xp yp and xq yp This concept of adjacency seems to be the most natural one for solutions in integers to an equation of the form x x xt k possibly subject to some other side constraints It has been applied to combinations e g Bitner Ehrlich and Reingold or Eades and McKay compositions e g as attributed to Knuth in Wilf and to integer partitions e g Savage Rasmussen Savage and West For each of these classes it was shown that there is an exhaustive listing of the elements in which successive elements on the list are adjacent under this criterion In this paper we seek a listing of the elements of C k n in which successive ele ments are adjacent Such a listing will be referred to as a Gray code for combinations of a multiset The problem of e ciently generating the combinations of a multiset in any order was also given in Reingold Nievergelt and Deo pg exercise but the associated solutions manual by Fill and Reingold contains no solution A loopfree algorithm called COMPOMAX was developed by Ehrlich In Ehrlich s al gorithm successive solutions di er in two adjacent positions but in those positions the elements may di er by more than one from their previous values Roelants van Baronaigien Ruskey and Engels provide a simpler constant amortized time gen eration algorithm which however is not a Gray code it generates the combinations in lexicographic order The Construction De ne a multiset combination x to be left extreme if xi implies either i or xi ni and right extreme if xi implies i n or xi ni Equivalently x is left right extreme if it is maximum minimum in C k n in the lexicographic ordering of t tuples For example in C is left extreme and is right extreme Let n n n nt Left and right extreme multiset combinations are unique although a multiset combination is both left and right extreme if k or k n since in these cases C k n has only one element We call a Gray code for combinations of a multiset extreme if it starts with the right extreme combination and ends with the left extreme combination Lemma If both C k n and C k n are nonempty then their right left extreme elements di er in only one position and in that position by one Proof If x x xt is right extreme for C k n there is an index j j t such that xi for i j and xi ni for t i j Then the right extreme element of C k n is obtained by adding to xj if xj nj and otherwise by adding to xj The left extreme case is similar Our Gray code construction is recursive with the basis cases covered in Lemmas and and the general case in Theorem If x C k n then xt must satisfy max k n nt xt min nt k Thus when t C k n can be partitioned as the disjoint union C k n min nt k xt max k n nt C k xt n nt Let G k n be the graph whose vertex set is C k n and where edges exist between vertices that are adjacent A Gray code for C k n is a Hamilton path in G k n Lemma There is an extreme Gray code listing of C k n when t and k n Proof Let p max k n and q max k n In this case G k n n is a path and there is only one possible list as shown below
منابع مشابه
O(1) Time Generation of Adjacent Multiset Combinations
We solve the problem of designing an O(1) time algorithm for generating adjacent multiset combinations in a different approach from Walsh [17]. By the word “adjacent”, we mean that two adjacent multiset combinations are different at two places by one in their vector forms. Previous O(1) time algorithms for multiset combinations generated non-adjacent multiset combinations. Our algorithm in this...
متن کاملFixed-Density Necklaces and Lyndon Words in Cool-lex Order
This paper creates a simple Gray code for fixed-density binary necklaces and Lyndon words. The Gray code is simultaneously a left-shift Gray code and a 2-transposition Gray code and is cyclic with these properties. It also has the advantage of using canonical representations (lexicographically minimum rotations) yielding the first known Gray code for Lyndon words ordered by density. This work s...
متن کاملShift Gray Codes
Combinatorial objects can be represented by strings, such as 21534 for the permutation (1 2) (3 5 4), or 110100 for the binary tree corresponding to the balanced parentheses (()()). Given a string s = s1s2⋯sn, the right-shift operation ÐÐ→ shift(s, i, j) replaces the substring sisi+1⋯sj by si+1⋯sjsi. In other words, si is right-shifted into position j by applying the permutation (j j−1 ⋯ i) to ...
متن کاملGray Images of Constacyclic Codes over some Polynomial Residue Rings
Let be the quotient ring where is the finite field of size and is a positive integer. A Gray map of length over is a special map from to ( . The Gray map is said to be a ( )-Gray map if the image of any -constacyclic code over is a -constacyclic code over the field . In this paper we investigate the existence of ( )-Gray maps over . In this direction, we find an equivalent ...
متن کاملREDUNDANCY OF MULTISET TOPOLOGICAL SPACES
In this paper, we show the redundancies of multiset topological spaces. It is proved that $(P^star(U),sqsubseteq)$ and $(Ds(varphi(U)),subseteq)$ are isomorphic. It follows that multiset topological spaces are superfluous and unnecessary in the theoretical view point.
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- Eur. J. Comb.
دوره 17 شماره
صفحات -
تاریخ انتشار 1996